<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <textarea name="" id="" cols="30" rows="10">123</textarea>
        <button>发布</button>
    </ul>
</body>
<script>
    var btn = document.querySelector('button')
    var text = document.querySelector('textarea')
    var ul = document.querySelector('ul')
    btn.onclick = function() {
        if (text.value == '0') {
            return alert('你没有输入内容');

        } else {
            var li = document.createElement('li')
            li.innerHTML = text.value
            ul.insertBefore(li, ul.children[0])
            text.value = ''
        }
    }
</script>

</html>